package com.py.custom.tms.application.jvm.classload;

public class MyTest25 implements Runnable{

    public static void main(String[] args) {
        new MyTest25();
    }

    private Thread thread;

    public MyTest25() {
        // new Thread(); 会获取当前线程的 线程上下文类加载器，并设置到Thread实例对象的属性中
        // 扩展：在new的过程还会判断当前线程的中 ThreadLocal.ThreadLocalMap inheritableThreadLocals
        //      并设置到 并设置到Thread实例对象的属性中。
        this.thread = new Thread(this);
        thread.start();
    }

    @Override
    public void run() {
        ClassLoader loader = this.thread.getContextClassLoader();
        this.thread.setContextClassLoader(loader);
        System.out.println("Class: " + loader.getClass());
        System.out.println("Parent: " + loader.getParent().getClass());
    }
}
